package robotleMvc.frameworks.tree
{
	import _Pan3D.core.MathCore;
	import _Pan3D.display3D.Display3DContainer;
	import _Pan3D.program.Program3DManager;
	import _Pan3D.program.shaders.BuildShader;
	import _Pan3D.program.shaders.BuildTreeShader;
	import _Pan3D.program.shaders.WillDeleShader;
	
	import flash.display3D.Context3D;
	import flash.display3D.Program3D;
	
	import org.robotlegs.mvcs.Actor;
	
	import robotleMvc.ui.tree.Tree3DSprite;
	
	import test.vo.StatVO;
	
	public class TreeModel extends Actor
	{
		private var treeItem:Array;
		private var treeSpriteItem:Array;
		public var context3D:Context3D;
		public var display3DContainer:Display3DContainer;
		public function TreeModel()
		{
			super();
		}
		public function praseTreeXmltoItem(_xml:XML):void
		{
	
			var _item:Array=MathCore.getSourcePro(_xml);
			treeItem=new Array;
			for (var i:int=0; i < _item.length; i++)
			{
				var statVO:StatVO=new StatVO;
				statVO.et=_item[i].et;
				statVO.scale=_item[i].scale * 3;
				statVO.x=_item[i].x;
				statVO.y=_item[i].y;
				statVO.z=_item[i].z;
				statVO.type=_item[i].type;
				statVO.id=i;
				
				statVO.name=_item[i].name;
				treeItem.push(statVO);
			}
			treeSpriteItem=new Array();
			for (var j:int=0; j < treeItem.length; j++)
			{
				var tempVo:StatVO=treeItem[j] as StatVO;
				var display3DSprite:Tree3DSprite=new Tree3DSprite(context3D);
				display3DSprite.url=tempVo.et
				display3DSprite.x=tempVo.x;
				display3DSprite.y=tempVo.y;
				display3DSprite.z=tempVo.z;
				display3DSprite.scale=tempVo.scale;
				display3DSprite.id=tempVo.id;
				display3DContainer.addChild(display3DSprite);
				treeSpriteItem.push(display3DSprite);
				
			}
			//var treeShaderProgram3d:Program3D=Program3DManager.getInstance().getProgram(WillDeleShader.WILL_DELE_SHADER);
			//display3DContainer.setProgram3D(treeShaderProgram3d);
			var treeShaderProgram3d:Program3D=Program3DManager.getInstance().getProgram( BuildTreeShader.BUILD_TREE_SHADER);
			display3DContainer.setProgram3D(treeShaderProgram3d);

	
		}
	}
}